package io;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

public class ReadAndWriteOneLine {
	public static void main(String args[]){
		File filein = new File("file/linein.txt");
		File fileout = new File("file/lineout.txt");
		try {
			FileReader fin = new FileReader(filein);
			BufferedReader in = new BufferedReader(fin);
			String content = "";
			String line = "";
			while((line = in.readLine())!=null){
				content+=line;
			}
			System.out.println(content);
			in.close();
			FileWriter fout = new FileWriter(fileout);
			BufferedWriter out = new BufferedWriter(fout);
			out.write(content);
			System.out.println("Dữ liệu đã được lưu ra file: "+fileout.getName());
			out.close();
		} catch (FileNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}
}
